/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package object;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.Shape;
import java.awt.geom.Arc2D;

import java.awt.geom.Ellipse2D;
import miscellaneous.Constant;

/**
 *
 * @author BBXP
 */
public class Citizen extends VisualObject {
    private Color skinColor;
    private boolean isAlive;
    private Shape shapeForHP;
    private Color hpColor;
    private int hp;

    public Citizen(int x, int y,int width, int height, Color skinColor){
        super(x, y, width, height);
        this.skinColor = skinColor;
        this.isAlive = true;
        Shape[] temp = constructShape();
        myShape = temp[SHAPE_FACE];
        mySelectedShadow = temp[SHAPE_SELECTED];
        shapeForHP = temp[SHAPE_HP];
        hpColor = Color.RED;
    }

    public void draw(Graphics2D g2d){
        //g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        if(isAlive){
            Color c = g2d.getColor();
            if(isSelected){
                g2d.setColor(Constant.selectColor);
                g2d.fill(mySelectedShadow);
            }
            g2d.setColor(skinColor);
            g2d.fill(myShape);
            g2d.setColor(hpColor);
            g2d.draw(shapeForHP);
        }
    }

    public Shape[] constructShape(){
        Shape[] tempShape = new Shape[3];
        tempShape[SHAPE_FACE] = new Ellipse2D.Float(x, y, width, height);
        tempShape[SHAPE_SELECTED] = new Ellipse2D.Float(x - SELECTED_OFFSET, y - SELECTED_OFFSET, width + SELECTED_OFFSET*2, height + SELECTED_OFFSET*2);
        tempShape[SHAPE_HP] = new Arc2D.Double(x+5, y+5, width-10, height-10, 180, 180, Arc2D.OPEN);
        return tempShape;
    }
}
